package logic

import (
	"context"
	"user_srv/user"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ListLogic {
	return &ListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ListLogic) List(req *types.AuthListReq) (resp *types.Resp, err error) {
	// todo: add your logic here and delete this line
	ms, err := l.svcCtx.UserSrv.AuthList(l.ctx, &user.AuthListRequest{})
	if err != nil {
		return &types.Resp{
			Mes:  err.Error(),
			Code: 500,
			Data: nil,
		}, nil
	}

	return &types.Resp{
		Mes:  "展示成功",
		Code: 200,
		Data: ms,
	}, nil
}
